package com.ethan.controller;


import com.ethan.req.LoginReq;
import com.ethan.service.SysUserService;
import com.ethan.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author Ethan
 * @since 2022-03-17
 */
@RestController
@Slf4j
public class SysUserController {

    @Autowired
    SysUserService sysUserService;

    @GetMapping("test1")
    @PreAuthorize("hasAuthority('test')")
    public R test() {

        log.info("test-----");
        return R.buildSuccess();
    }

    @PostMapping("/mobile/login")
    public R login(@RequestBody LoginReq loginReq) {
        return sysUserService.login(loginReq);
    }


}

